home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10719 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  46 lines

  1. Path: inforamp.net!ts6-06
  2. From: rmorin@inforamp.net (Randy Charles Morin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: help with array initialization
  5. Date: Sat, 09 Mar 96 19:28:57 GMT
  6. Organization: MiddleWorld SoftWare
  7. Message-ID: <4hsm66$rsm@sam.inforamp.net>
  8. References: <31409BCC.2FCD@ovnet.com>
  9. NNTP-Posting-Host: ts6-06.tor.inforamp.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <31409BCC.2FCD@ovnet.com>,
  13.    Michael Wallace <mjwpop@ovnet.com> wrote:
  14. >I am a student learning c++ and have a question concerning initialization 
  15. >of arrays.  The textbook I am using (C++, How to program) says that you 
  16. >can initialize arrays in this manner - int array[100]={0}; anytime.  
  17. >However, trying to compile this with Borland Turbo C++ 4.5 gives an 
  18. >error, it only allows that type of initialization if the variable is 
  19. >declared static.  I have another reference manual (C++, The Complete 
  20. >Reference) and as far as I can find, it doesn't say which is correct. If 
  21. >someone would please tell me if the textbook or the comipiler is correct?
  22.  
  23. I compiled and ran...
  24. -----------------------------------
  25.     int main()
  26.     {
  27.         int array[100]={0};
  28.         array[0]=1;
  29.         return array[0];
  30.     };
  31. -----------------------------------
  32. ..successfully with Borland 4.5 and Borland 4.52.
  33. I also tried...
  34. ------------------------------------
  35.     int main()
  36.     {
  37.         static int array[100]={0};
  38.         array[0]=1;
  39.         return array[0];
  40.     };
  41. -------------------------------------
  42. ..without any problems.  
  43. Just thought you'd want to know I couldn't reproduce the problem.
  44.  
  45. Agrivar
  46.